//
//  CZJCMainController.swift
//  SinaWeibo
//
//  Created by mac on 15/10/6.
//  Copyright © 2015年 cz. All rights reserved.
//

import UIKit

class CZJCMainController: UITabBarController {

    @IBOutlet weak var mainTabbar: CZJCMainTabBar!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        addChildViewControllers()
        //添加中间按钮的点击事件
        mainTabbar.composeBtn.addTarget(self, action: "composeDidClick", forControlEvents: UIControlEvents.TouchUpInside)
      
    }
    
    func composeDidClick(){
        print(__FUNCTION__)
    }
    
    //添加所有子视图控制器
   private func addChildViewControllers() {
        //设置
        self.tabBar.tintColor = UIColor.orangeColor()
        
        addChildrenViewController("Home","首页", "tabbar_home")
        addChildrenViewController("Message","消息", "tabbar_message_center")
        addChildrenViewController("Discover","发现", "tabbar_discover")
        addChildrenViewController("Profile","我", "tabbar_profile")
        
    }

    //添加单视图控制器
   private func addChildrenViewController(sbName:String, _ title:String, _ imageName:String) {
        let sb = UIStoryboard(name: sbName, bundle: nil)
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        //设置标题
        nav.topViewController?.title = title
        //设置图片
        nav.tabBarItem.image = UIImage(named: imageName)
        addChildViewController(nav)
        
    }

}
